import request from './ajax'

// 发送登录请求，发送表单数据
export const postLogin = (loginForm) => {
  return request({
    url: '/private/v1/login',
    method: 'post',
    data: loginForm
  })
}
// 左侧菜单
export const getMenu = () => {
  return request({
    url: '/private/v1/menus',
    method: 'get'
  })
}

export const reqBannerList = (goodId) => {
  return request({
    url: `/good/${goodId}`,
    method: 'post'
    // data: good_id
  })
}
// 获取用户列表
export const getUsers = (queryInfo) => {
  return request({
    url: '/private/v1/users',
    method: 'get',
    params: queryInfo
  })
}
// 改变用户状态
export const changeUserState = (id, state) => {
  return request({
    url: `/private/v1/users/${id}/state/${state}`,
    method: 'put'
    // data: good_id
  })
}
// 添加用户
export const addUser = (userInfo) => {
  return request({
    url: '/private/v1/users',
    method: 'post',
    data: userInfo
  })
}
// 获取用户信息
export const getUserInfo = (id) => {
  return request({
    url: `/private/v1/users/${id}`,
    method: 'get'
  })
}
// 修改用户
export const editUserInfo = (id, userInfo) => {
  return request({
    url: `/private/v1/users/${id}`,
    method: 'put',
    data: userInfo
  })
}
// 删除u用户
export const deleUser = (id) => {
  return request({
    url: `/private/v1/users/${id}`,
    method: 'delete'
  })
}
// 获取角色
export const getRoles = () => {
  return request({
    url: '/private/v1/roles',
    method: 'get'
  })
}
// 删除角色
export const removeRoleTag = (roleId, rightId) => {
  return request({
    url: `/private/v1/roles/${roleId}/rights/${rightId}`,
    method: 'delete'
  })
}
// 获取角色列表
export const getRight = () => {
  return request({
    url: '/private/v1/rights/tree',
    method: 'get'
  })
}
// 设置权限
export const setUserPower = (id, idstr) => {
  return request({
    url: `/private/v1/roles/${id}/rights`,
    method: 'post',
    data: idstr
  })
}

export const setRole = () => {
  return request({
    url: '/private/v1/roles',
    method: 'get'
  })
}
// 保存角色信息
export const saveRoleInfo = (id, rId) => {
  return request({
    url: `/private/v1/users/${id}/role`,
    method: 'put',
    data: rId
  })
}
// 获取分类列表
export const getCategoriesList = (queryinfo) => {
  return request({
    url: '/private/v1/categories',
    method: 'get',
    params: queryinfo
  })
}

export const getCateList = (queryinfo) => {
  return request({
    url: '/private/v1/categories',
    method: 'get',
    params: queryinfo
  })
}
// 获取商品分类树
export const addCategories = (queryinfo) => {
  return request({
    url: '/private/v1/categories',
    method: 'post',
    data: queryinfo
  })
}
// 获取商品列表
export const goodsList = (queryinfo) => {
  return request({
    url: '/private/v1/goods',
    method: 'get',
    params: queryinfo
  })
}
// 删除商品
export const deleGoods = (id) => {
  return request({
    url: `/private/v1/goods/${id}`,
    method: 'delete'
  })
}
// 获取商品属性
export const cateAttributes = (id, queryinfo) => {
  return request({
    url: `/private/v1/categories/${id}/attributes`,
    method: 'get',
    params: queryinfo
  })
}

// 添加商品
export const addGoods = (queryinfo) => {
  return request({
    url: '/private/v1/goods',
    method: 'post',
    data: queryinfo
  })
}
